package me.lc.hammerheads.sprite.dwarfUnit;

import com.wiyun.engine.nodes.Animation;
import com.wiyun.engine.nodes.Sprite;
import com.wiyun.engine.types.WYRect;

import me.lc.hammerheads.core.GameSystem;
import me.lc.hammerheads.sprite.Dwarf;
import me.lc.hammerheads.util.AudioHelper;

/**
 * 金属矮人
 * 
 * @author Administrator
 * 
 */
public class DwarfSilver extends Dwarf {

	private static float ItemWidth = GameSystem.tex_sliverMan.getWidth() / 7.0f;
	private static float ItemHeight = GameSystem.tex_sliverMan.getHeight();
	private int leaveLife = getLifeCount();

	@Override
	protected void createDwart() {
		dwarf = Sprite.make(GameSystem.tex_sliverMan, frameAt(0));
	}

	@Override
	public int knock(int power) {
		// 根据当前的血量展示不同的状态
		leaveLife -= power;
		blood.update(leaveLife);
		AudioHelper.silverKnock();
		if (leaveLife <= 0) {
			dwarf.setTextureRect(frameAt(6));
			knockOut();
		} else {
			dwarf.setTextureRect(frameAt(5 - leaveLife));
		}
		return 1;
	}

	@Override
	protected int getLifeTime() {
		return 10;
	}

	@Override
	protected int getLifeCount() {
		return 3;
	}

	@Override
	protected float getDwarfX() {
		return 0;
	}

	@Override
	protected void doDwarfAction() {
	}

	@Override
	protected float getDwarfWidth() {
		return ItemWidth;
	}

	private WYRect frameAt(int x) {
		return WYRect.make(x * ItemWidth, 0, ItemWidth, ItemHeight);
	}

	@Override
	protected int getKnockoutScore() {
		return 500;
	}
}
